package com.google.code.puertorico

object TradingHouse {

  def initialTradingHouse: TradingHouse = TradingHouse(None, None, None, None);

}

case class TradingHouse(slot1: Option[Barrel], slot2: Option[Barrel], slot3: Option[Barrel], slot4: Option[Barrel]) {

  def isFull: Boolean = !isNotFull;

  def isNotFull: Boolean = slot1.isEmpty || slot2.isEmpty || slot3.isEmpty || slot4.isEmpty;

  def hasCorn: Boolean = barrels.exists(_ == CornBarrel);

  def hasIndigo: Boolean = barrels.exists(_ == IndigoBarrel);

  def hasSugar: Boolean = barrels.exists(_ == SugarBarrel);

  def hasTobacco: Boolean = barrels.exists(_ == TobaccoBarrel);

  def hasCoffee: Boolean = barrels.exists(_ == CoffeeBarrel);

  def barrels: List[Barrel] = List(slot1, slot2, slot3, slot4).flatten;

  def isBarrel(slot: Option[Barrel], barrel: Barrel): Boolean = slot match {
    case Some(b) => b == barrel;
    case None => false;
  }

}
